<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>GEN27</title>
    <link rel="stylesheet" type="text/css" href="csound.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" />
    <link rel="up" href="ScoregensTop.html" title="Score Statements and GEN Routines" />
    <link rel="prev" href="GEN25.html" title="GEN25" />
    <link rel="next" href="GEN28.html" title="GEN28" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">GEN27</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="GEN25.html">Prev</a> </td>
          <th width="60%" align="center">Score Statements and GEN Routines</th>
          <td width="20%" align="right"> <a accesskey="n" href="GEN28.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry">
      <a id="GEN27"></a>
      <div class="titlepage"></div>
      <a id="IndexGEN27" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">GEN27</span>
        </h2>
        <p>GEN27 — 
      Construct functions from segments of straight lines in breakpoint fashion.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp215229360"></a>
        <h2>Description</h2>
        <p>
      Construct functions from segments of straight lines in breakpoint fashion.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp215230544"></a>
        <h2>Syntax</h2>
        <pre class="synopsis"><span class="command"><strong>f</strong></span> # time size 27 x1  y1 x2 y2 x3 ...</pre>
      </div>
      <div class="refsect1">
        <a id="idp215232528"></a>
        <h2>Initialization</h2>
        <p>
      <span class="emphasis"><em>size </em></span> -- number of points in the table. Must be a power of 2 or power-of-2 plus 1 (see <a class="link" href="f.html" title="f Statement (or Function Table Statement)"><em class="citetitle">f statement</em></a>).
    </p>
        <p>
      <span class="emphasis"><em>x1, x2, x3,</em></span> etc. -- locations in table at which to attain the following y value. Must be in increasing order. If the last value is less than size, then the rest will be set to zero. Should not be negative but can be zero.
    </p>
        <p>
      <span class="emphasis"><em>y1, y2, y3,</em></span>, etc. -- Breakpoint values attained at the location specified by the preceding x value.
    </p>
        <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
          <table border="0" summary="Note: Note">
            <tr>
              <td rowspan="2" align="center" valign="top" width="25">
                <img alt="[Note]" src="images/note.png" />
              </td>
              <th align="left">Note</th>
            </tr>
            <tr>
              <td align="left" valign="top">
                <p>
        If p4 is positive, functions are post-normalized (rescaled to a maximum absolute value of 1 after generation). A negative p4 will cause rescaling to be skipped.
      </p>
              </td>
            </tr>
          </table>
        </div>
      </div>
      <div class="refsect1">
        <a id="idp215304640"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the GEN27 opcode. It uses the file <a class="ulink" href="examples/gen27.csd" target="_top"><em class="citetitle">gen27.csd</em></a>.
           </p>
        <div class="example">
          <a id="idp215306416"></a>
          <p class="title">
            <strong>Example 1115. Example of the GEN27 opcode.</strong>
          </p>
          <div class="example-contents">
            <p>See the sections <a class="link" href="UsingRealTime.html" title="Real-Time Audio"><em class="citetitle">Real-time Audio</em></a> and <a class="link" href="CommandFlags.html" title="Csound command line"><em class="citetitle">Command Line Flags</em></a> for more information on using command line flags.</p>
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
<span class="comment">; Select audio/midi flags here according to platform</span>
-odac  <span class="comment">;;;realtime audio out</span>
<span class="comment">;-iadc    ;;;uncomment -iadc if realtime audio input is needed too</span>
<span class="comment">; For Non-realtime ouput leave only the line below:</span>
<span class="comment">; -o gen27.wav -W ;;; for file output any platform</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>

<span class="ohdr">sr</span> <span class="op">=</span> 44100
<span class="ohdr">ksmps</span> <span class="op">=</span> 32
<span class="ohdr">nchnls</span> <span class="op">=</span> 2
<span class="ohdr">0dbfs</span>  <span class="op">=</span> 1

gisin <span class="ohdr">ftgen</span> 1, 0, 32768, 10, 1
gienv <span class="ohdr">ftgen</span> 2, 0, 1025, 27, 0, 0,200, 1, 400, <span class="op">-</span>1, 513, 0
  
<span class="oblock">instr</span> 1

kcps <span class="opc">init</span> 3<span class="op">/</span>p3			<span class="comment">;play 3x over duration of note</span>
kndx <span class="opc">phasor</span> kcps
ixmode <span class="op">=</span> 1			<span class="comment">;normalize to 0-1</span>
kval <span class="opc">table</span> kndx, gienv, ixmode
kval <span class="op">=</span> kval<span class="op">*</span>100			<span class="comment">;scale 0-100</span>
asig <span class="opc">poscil</span> 1, 220<span class="op">+</span>kval, 1	<span class="comment">;add to 220 Hz</span>
     <span class="opc">outs</span> asig, asig
  
<span class="oblock">endin</span>
<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>

<span class="stamnt">i</span> 1 0 4

<span class="stamnt">e</span>
<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />  
        <span class="phrase">This is the diagram of the waveform of the GEN27 routine, as used in the example:</span>

      </p>
        <div class="mediaobject">
          <img src="images/gen27.png" alt="f 2 0 1025 27 0 0 200 1 400 -1 513 0 - a function which begins at 0, rises to 1 at the 200th table location, falls to -1, by the 400th location, and returns to 0 by the end of the table. The interpolation is linear" />
          <div class="caption">
            <p>f 2 0 1025 27 0 0 200 1 400 -1 513 0 - a function which begins at 0, rises to 1 at the 200th table location, falls to -1, by the 400th location, and returns to 0 by the end of the table. The interpolation is linear</p>
          </div>
        </div>
        <p>
   
    </p>
      </div>
      <div class="refsect1">
        <a id="idp215315056"></a>
        <h2>See Also</h2>
        <p>
      <a class="link" href="f.html" title="f Statement (or Function Table Statement)"><em class="citetitle">f statement</em></a>,
      <a class="link" href="GEN25.html" title="GEN25"><em class="citetitle">GEN25</em></a>
    </p>
      </div>
      <div class="refsect1">
        <a id="idp215318064"></a>
        <h2>Credits</h2>
        <p>
      </p>
        <table border="0" summary="Simple list" class="simplelist">
          <tr>
            <td>Author: John ffitch</td>
          </tr>
          <tr>
            <td>University of Bath/Codemist Ltd.</td>
          </tr>
          <tr>
            <td>Bath, UK</td>
          </tr>
        </table>
        <p>
    </p>
        <p>New in Csound version 3.49</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="GEN25.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="ScoregensTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="GEN28.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">GEN25 </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> GEN28</td>
        </tr>
      </table>
    </div>
  </body>
</html>
